package net.learn.system.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.learn.framework.common.page.PageResult;
import net.learn.framework.common.utils.Result;
import net.learn.system.query.SysJudgeQuery;
import net.learn.system.query.SysMyPaperQuery;
import net.learn.system.service.SysJudgeService;
import net.learn.system.service.SysMyPaperService;
import net.learn.system.vo.SysJudgeVO;
import net.learn.system.vo.SysMyPaperVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 我的试卷
 */
@RestController
@RequestMapping("sys/mypaper")
@Tag(name="我的试卷")
@AllArgsConstructor
public class SysMyPaperController {
    @Autowired
    private final SysMyPaperService sysMyPaperService;

    @GetMapping("getMyPaper")
    @Operation(summary = "分页获取我的试卷列表")
    public Result<PageResult<SysMyPaperVO>> getMyPaper(@Valid SysMyPaperQuery query){
        PageResult<SysMyPaperVO> page = sysMyPaperService.qryMyPaperListPage(query);

        return Result.ok(page);
    }
    @PostMapping("getMyPaperList")
    @Operation(summary = "获取我的试卷列表")
    public Result<List<SysMyPaperVO>> getMyPaperList(@RequestBody SysMyPaperQuery query){
        List<SysMyPaperVO> list = sysMyPaperService.qryMyPaperQuestionList(query);

        return Result.ok(list);
    }
    @GetMapping("qryMyPaperCondition")
    @Operation(summary = "获取已经交卷的试卷列表")
    public Result<PageResult<SysMyPaperVO>> qryMyPaperCondition(@Valid SysMyPaperQuery query){
        PageResult<SysMyPaperVO> page = sysMyPaperService.qryMyPaperCondition(query);

        return Result.ok(page);
    }
    @GetMapping("qryMyPaperCondition")
    @Operation(summary = "获取已经交卷的试卷列表")
    public Result<PageResult<SysMyPaperVO>> getMyPaperGroup(@Valid SysMyPaperQuery query){
        PageResult<SysMyPaperVO> page = sysMyPaperService.qryMyPaperGroup(query);

        return Result.ok(page);
    }
    @GetMapping("getMyPaperView")
    @Operation(summary = "获取已经交卷的全部试卷列表")
    public Result<PageResult<SysMyPaperVO>> getMyPaperView(@Valid SysMyPaperQuery query){
        PageResult<SysMyPaperVO> page = sysMyPaperService.qryMyPaperView(query);

        return Result.ok(page);
    }
    @PostMapping("/updateMyPaper")
    @Operation(summary = "修改我的试卷")
    public Result<String> updateMyPaper(@RequestBody @Valid SysMyPaperVO vo){
        sysMyPaperService.updateMyPaper(vo);

        return Result.ok();
    }
    @PostMapping("save")
    @Operation(summary = "新增试卷")
    public Result<String> save(@RequestBody SysMyPaperVO vo){
        sysMyPaperService.addMyPaper(vo);

        return Result.ok();
    }

    @DeleteMapping
    @Operation(summary = "删除")
    public Result<String> deleteById(@RequestBody List<Long> idList){
        sysMyPaperService.delete(idList);
        return Result.ok();
    }
}

